<template>
    <div class="func-box">
        <div v-for="(i,index) in func_buttons">
            <Button :type="i.button" @click="i.onclick">{{ i.name }}</Button>
        </div>
    </div>
    
</template>

<script setup>
import { inject, ref,defineProps, onMounted } from "vue";
import { response_to_request } from "@/api/chat/user_behavior"
import { get_room_info_all_by_room_id_type}from"@/api/chat/room"
const chat = inject('chat')()
const props = defineProps({
    info: {
        type:Object,
    }
})

const func_buttons = [
    {
        'name': '同意',
        'onclick':async () => { 
            if (props.info.room_type == 'group') { 
                const judge = await response_to_request(chat?.value?.get_user_info()?.id, 1, props.info)
                if (judge.status == 200) { 
                    chat.value.pop_request_room_data(props?.info.room_id)
                    chat.value.add_group_item(await get_room_info_all_by_room_id_type(props.info.room_id,'group'))
                }
            }
            if (props.info.room_type == 'double') { 
                console.log(props?.info)
                const judge = await response_to_request(chat?.value?.get_user_info()?.id, 1,
                    [chat?.value?.get_user_info()?.id, props?.info?.meta?.id])
                if (judge.status == 200) { 
                    chat.value.pop_request_room_data(props?.info.room_id)
                    chat.value.add_friend_item(
                        await get_room_info_all_by_room_id_type(props.info.room_id, 'double',chat?.value?.get_user_info()?.id))
                }
            }
        },
        'button': 'primary',
        'show_confirm': false,
        'need_confim':false
    },
    {
        'name':'拒绝',
        'onclick': async () => { 
            if (props.info.room_type == 'group') { 
                const judge = await response_to_request(chat?.value?.get_user_info()?.id, -1, props.info)
                if (judge.status == 200) { 
                    chat.value.pop_request_room_data(props?.info.room_id)
                }
            }
            if (props.info.room_type == 'double') { 
                const judge = await response_to_request(chat?.value?.get_user_info()?.id, -1,
                    [chat?.value?.get_user_info()?.id, props?.info?.meta?.id])
                if (judge.status == 200) { 
                    chat.value.pop_request_room_data(props?.info.room_id)
                }
            }
        },
        'button': 'error',
        'show_confim': false,
    }
] 
const show_confirm = ref(false)
const deal_true_quit_del_room = async() => {


}
const deal_false_quit_del_room = async () => { 
    
}
onMounted(() => {
    // console.log(props.info)
})


</script>

<style  scoped>
.func-box{
    display: flex;
    gap:2px;
    flex-direction: row;
    justify-self: center;
    align-items: center;
    height: 100%;


     /* 玻璃效果核心代码 */
     background: rgba(255, 255, 255, 0.2); /* 半透明白色基底 */
    backdrop-filter: blur(10px); /* 关键：毛玻璃模糊效果 */
    -webkit-backdrop-filter: blur(10px); /* 兼容 Safari */
    border-radius: 8px; /* 圆角增强玻璃质感 */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 轻微阴影提升层次 */
    border: 1px solid rgba(255, 255, 255, 0.3); /* 透明边框增强边缘光感 */
}

</style>